package model;

import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
public class ClassEditor implements Observer{
	private Class classToEdit;
	public ClassEditor(Class classToEditIn){
		
	}
	
	public void commitEdits(String nameIn, int oXIn, int oYIn, int sizeXIn, int sizeYIn, Vector<Attribute> attributesIn, Vector<Operation> operationsIn, boolean changedAts, boolean changedOps) {
		classToEdit.setName(nameIn);
		classToEdit.setoX(oXIn);
		classToEdit.setoY(oYIn);
		classToEdit.setSizeX(sizeXIn);
		classToEdit.setSizeY(sizeYIn);
		if(changedAts){
			classToEdit.setAttributes(attributesIn);
		}
		if(changedOps){
			classToEdit.setOperations(operationsIn);
		}
		
	}
	public void update(Observable obj, Object arg){
		if (arg instanceof Class){
			this.classToEdit = (Class) arg;
		}
		if (arg instanceof Relationship){
			this.classToEdit = null;
		}
		
	}
	
	public Vector<Attribute> getAttributeList(){
		return classToEdit.getAttributes();
	}
	
	public Vector<Operation> getOperation(){
		return classToEdit.getOperations();
	}
	
	public String getName(){
		return classToEdit.getName();
	}
	
	public int getXPos(){
		return classToEdit.getoX();
	}
	
	public int getyPos(){
		return classToEdit.getoY();
	}
	
	public int getSizeX(){
		return classToEdit.getSizeX();
	}
	
	public int getySizeY(){
		return classToEdit.getSizeY();
	}
}
